package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.GoodsBeen;
import cn.xfdzx.android.apps.shop.contract.ItemClickListener;

/**
 * @author gzk
 * @date 2020/4/13 0013
 * description：
 */
public class GoodsDetailsTuiJianAdapter extends RecyclerView.Adapter<GoodsDetailsTuiJianAdapter.MyViewHolder>{

    private ItemClickListener mItemClickListener;
    private List<GoodsBeen> list;
    private Context context;

    public void setList(List<GoodsBeen> list) {
        notifyDataSetChanged();
        this.list = list;
    }

    public GoodsDetailsTuiJianAdapter(Context context, List <GoodsBeen> list) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_goods_tui_jian, parent, false);
        MyViewHolder myHolder = new MyViewHolder(inflate);

        return myHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
//        holder. tvShopGoodsName.setText(list.get(position).name);
//        holder.ivShopPicture.setImageResource(list.get(position).image_id);
//
//        holder.tvShopMonthSale.setText(list.get(position).sale);
//        holder.tvShopHighPraise.setText(list.get(position).highPraise);
//        holder.tvShopGoodsPrice.setText(list.get(position).goodsPrice);
//        holder. tvShopGoodsPriceOld.setText(list.get(position).goodsPriceOld);
        holder. tvShopGoodsPriceOld.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);


//        holder.itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mItemClickListener.onItemClick(position);
//            }
//        });
    }



    @Override
    public int getItemCount() {
        return 0;
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_shop_goods_name)
        TextView tvShopGoodsName;
        @BindView(R.id.iv_shop_picture)
        ImageView ivShopPicture;

        @BindView(R.id.tv_shop_goods_price)
        TextView tvShopGoodsPrice;
        @BindView(R.id.tv_shop_goods_price_old)
        TextView tvShopGoodsPriceOld;
        @BindView(R.id.tv_goods_add)
        TextView tvGoodsAdd;
//        @BindView(R.id.iv_goods_minus)
//        TextView ivGoodsMinus;
        @BindView(R.id.tv_goods_num)
        TextView tvGoodsNum;
        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);

        }
    }



    public void setOnItemClickListener(ItemClickListener itemClickListener) {
        this.mItemClickListener = itemClickListener;

    }

}
